package com.asset.dispoal.batchEvidenceTypeMapper.service.commom;

import com.asset.dispoal.batchEvidenceTypeMapper.domain.db.entity.SysBatchEvidenceTypeMapper;
import com.asset.dispoal.batchEvidenceTypeMapper.domain.db.mapper.SysBatchEvidenceTypeMapperMapper;
import com.asset.dispoal.batchEvidenceTypeMapper.dto.SysBatchEvidenceTypeMapperRequest;
import com.asset.dispoal.batchEvidenceTypeMapper.service.converter.SysBatchEvidenceTypeMapperConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import tech.mhuang.pacebox.core.ddd.BaseCommand;
import tech.mhuang.pacebox.core.id.BaseIdeable;
import tech.mhuang.pacebox.springboot.protocol.Result;

/**
 * @author qr
 * @date 2022/3/25$
 */
@Component
public class SysBatchEvidenceTypeMapperInsertCommand implements BaseCommand<SysBatchEvidenceTypeMapperRequest, Result> {

    @Autowired
    SysBatchEvidenceTypeMapperMapper sysBatchEvidenceTypeMapperMapper;

    @Autowired
    private BaseIdeable<String> ideable;

    @Override
    public Result execute(SysBatchEvidenceTypeMapperRequest request) {
        SysBatchEvidenceTypeMapper sysBatchEvidenceTypeMapper = SysBatchEvidenceTypeMapperConverter.INSTANCE.resToDo(request);
        sysBatchEvidenceTypeMapper.setId(ideable.generateId());
        sysBatchEvidenceTypeMapperMapper.insert(sysBatchEvidenceTypeMapper);
        return Result.ok();
    }
}
